/**
 * 
 */
package controller;

import components.exceptions.UnexpectedNotifyReceivedException;
import components.register.RegisterGroup;

import controller.notify.Notify;

/**
 * @author Chz
 * 
 */
public class MachineFaultController extends Controller {

	private static MachineFaultController self;
	private Notify notify = null;

	/*
	 * (non-Javadoc)
	 * 
	 * @see controller.Notifiable#notify(controller.notify.Notify)
	 */
	@Override
	public void notify(Notify n) {
		notify = n;
		System.err.println("Notify received in MachineFaultController!");
	}

	private MachineFaultController() {

	}

	/**
	 * get the singleton instance of MachineFaultCsontroller.
	 * 
	 * @return an instance of MachineFaultController
	 */
	public static MachineFaultController getInstance() {
		if (self == null)
			self = new MachineFaultController();

		return self;
	}

	/**
	 * If a machine fault occurs, call this method. This method will set the MFR
	 * with correct value and then call the machine fault handler.
	 * 
	 * @param fault
	 */
	public static void sendMachineFault(int fault) {
		// set MFR
		RegisterGroup.getInstance().setMFR(fault);
		// call machine fault handler which is in address 1
		machineFaultHandler();
	}

	private static void machineFaultHandler() {
		// TODO: TO BE FINISHED
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub
		
	}

}
